// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';

module.exports = {
  meta: {
    type: 'problem',
    docs: {
      description: 'enforce const enum in TypeScript',
      category: 'Possible Errors',
    },
    fixable: 'code',
    schema: []  // no options
  },
  create: function(context) {
    return {
      TSEnumDeclaration(node) {
        const isConstEnum = node.const === true;

        if (!isConstEnum) {
          context.report({node, message: 'TypeScript enums must be declared as const enums: const enum Foo {...}'});
        }
      }
    };
  }
};
